const express=require('express')
const cors=require('cors')

const branchRouter=require('./routers/branch')
const dishRouter=require('./routers/dish')
const usersRouter=require('./routers/users')
const orderRouter=require('./routers/order')

const app=express()
app.listen(3000,()=>{
    console.log('3000端口服务器启动了')
})

app.use(cors())
app.use(express.static('public'))

app.use(express.urlencoded({extended:true}))

app.use('/branch',branchRouter)
app.use('/dish',dishRouter)
app.use('/users',usersRouter)
app.use('/order',orderRouter)

app.use((err,req,res,next)=>{
    console.log(err)
    res.send({code:500,msg:'服务器端错误'})
})